#include <iostream>
#include <typeinfo>
#include <vector>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ret;
    vector<vector<int>> vet(n + 1);
    queue<int> q;
    vector<int> arr(n + 1);
    while (m--)
    {
        int a, b;
        cin >> a >> b;
        vet[a].push_back(b);
        arr[b]++;
    }
    for (int i = 1; i <= n; i++)
    {
        if (arr[i] == 0)
        {
            q.push(i);
        }
    }
    while (q.size())
    {
        int a = q.front();
        ret.push_back(a);
        q.pop();
        for (auto b : vet[a])
        {
            arr[b]--;
            if (arr[b] == 0)
            {
                q.push(b);
            }
        }
    }
    if (ret.size() == n)
    {
        for (int i = 0; i < n - 1; i++)
        {
            cout << ret[i] << " ";
        }
        cout << ret[n - 1] << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}

priority_queue<int> q;
unordered_map<int, int> cnt;
int n, m;

bool check(int x)
{
    int g = 0;
    for (auto& [a, b] : cnt)
    {
        g += b / x + (b % x == 0 ? 0 : 1);
    }
    return g <= m;
}

int main() {
    cin >> n >> m;
    int hmax = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x]++;
        hmax = max(hmax, cnt[x]);
    }
    if (m < cnt.size())
    {
        cout << "-1" << endl;
    }
    else
    {
        for (int i = 1; i <= hmax; i++)
        {
            if (check(i))
            {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

class Solution {
public:
    string formatString(string str, vector<char>& arg) {
        // write code here
        int n = arg.size();
        int p = str.size();
        string ret;
        int i = 0;
        int k = 0;
        while (i < p)
        {
            if (i + 1 < p && str[i] == '%' && str[i + 1] == 's')
            {
                ret += arg[k];
                k++;
                i++;
            }
            else
            {
                ret += str[i];
            }
            i++;
        }
        while (k < n)
        {
            ret += arg[k];
            k++;
        }
        return ret;
    }
};


int main() {
    string str;
    double k;
    cin >> str >> k;
    int n = str.size();
    if (k > n)
    {
        cout << str << endl;
        return 0;
    }
    int left = 0;
    int right = 0;
    int my_left = 0;
    int my_right = 0;
    int sum = 0;
    double MAX = 0.0;
    while (right < n)
    {
        if (str[right] == 'C' || str[right] == 'G')
        {
            sum++;
        }
        while (right - left + 1 > k)
        {
            if (str[left] == 'C' || str[left] == 'G')
            {
                sum--;
            }
            left++;
        }
        if (right - left + 1 == k & sum / k > MAX)
        {
            my_left = left;
            my_right = right;
            MAX = sum / k;
        }
        right++;
    }
    string ret = str.substr(my_left, my_right - my_left + 1);
    cout << ret << endl;
    return 0;
}

bool isprim(int n)
{
    if (n < 2)
    {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

bool dfs(int n)
{
    vector<int> num;
    while (n)
    {
        num.push_back(n % 10);
        n /= 10;
    }
    for (int i = 0; i < num.size(); i++)
    {
        for (int j = 0; j < num.size(); j++)
        {
            if (i != j && num[i] != 0 && num[j] % 2 != 0)
            {
                if (isprim(num[i] * 10 + num[j]))
                {
                    return true;
                }
            }
        }
    }
    return false;
}

int main() {
    int n, m;
    cin >> n >> m;
    int ret = 0;
    for (int i = max(n, 10); i <= m; i++)
    {
        if (dfs(i))
        {
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}